{# The worker's queues, re-sent over SSE when they change: totals, a card per queue read left to right (waiting, running, done, then how the backlog is trending) and each queue's share of the waiting and finished work. #} {% from "components/macros/layout.html" import stats_strip, card, badge %} {% from "components/macros/feedback.html" import empty_state %} {% set w = worker %} {% macro shares(key, total, label) %}
{{ label }}{{ "{:,}".format(total) }}
{% for q in w.queues %}{% set share = q[key ~ "_share"] %} {% if share %}{% endif %} {% endfor %}
{% endmacro %}
{{ stats_strip([ {"label": "Running", "value": w.busy ~ " / " ~ w.slots, "caption": w.busy_pct ~ "% of capacity"}, {"label": "Waiting", "value": "{:,}".format(w.queued), "caption": "across " ~ w.queues|length ~ (" queue" if w.queues|length == 1 else " queues")}, {"label": "Completed", "value": "{:,}".format(w.completed), "caption": (w.success ~ "% succeeded") if w.success is not none else "no runs yet", "tone": "ok" if w.success_color == "green" else none}, {"label": "Failed", "value": "{:,}".format(w.failed), "tone": "error" if w.failed else none}, ], id="worker-figures") }}
{% for q in w.queues %} {% set cells = [q.slots, 40]|min %} {% set lit = ((q.busy_pct * cells / 100)|round(0, "ceil")|int) if q.busy else 0 %} {% set finished = q.completed + q.failed %}

{{ q.name }}

{% if q.description %}

{{ q.description }}

{% endif %}
{{ badge(q.state ~ (" · " ~ q.detail if q.detail else ""), q.tone) }}
Waiting{{ "{:,}".format(q.queued) }}
{% for i in range(40) %}{% endfor %}

{% if q.pile.per_block > 1 %}1 block ≈ {{ "{:,}".format(q.pile.per_block) }} jobs{% else %}each block is a job{% endif %}{% if q.oldest %} · oldest {{ q.oldest }}{% endif %}

Running{{ q.busy }}
{% for i in range(cells) %}{% endfor %}

{{ q.busy }} of {{ q.slots }} at once · {{ q.busy_pct }}% of capacity

Done{{ "{:,}".format(q.completed) }}
{% if finished %}{% endif %}

{{ "{:,}".format(q.failed) }} failed{% if q.success is not none %} · {{ q.success }}%{% endif %}{% if q.rate %} · {{ q.rate }} jobs/s{% endif %}

Waiting, last 5 min
{{ q.drain }}

{{ q.consumers }} {{ "consumer" if q.consumers == 1 else "consumers" }}{% if q.timeout %} · {{ q.timeout }}s timeout{% endif %}{% if q.stream %} · {{ q.stream }}{% endif %}

{% else %} {% if w.problem %}

{{ w.problem }}

{% else %} {{ empty_state("No queues reporting", "Queues appear here once a worker is running and has registered them.") }} {% endif %} {% endfor %}
{% if w.queues %} {% call card("Share of the work", "Each queue's part of what is waiting and of what has finished", id="worker-distribution") %}
{{ shares("backlog", w.queued, "Waiting") }} {{ shares("work", w.completed + w.failed, "Finished") }}
{% for q in w.queues %}{{ q.name }}{% endfor %}
{% endcall %} {% endif %}